Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
初入Python,问问各位大佬怎么调用root授权窗口
deepin Talks
1168
views ·
12
replies ·
To
floor
Go
星外之神
deepin
2017-05-13 21:35
Author
如题,Python-Qt5怎么调用root授权窗口,
Reply
Like 0
Favorite
View the author
All Replies
q_q
deepin
2017-05-13 21:55
#1
不知道。。。
Reply
Like 0
View the author
星外之神
deepin
2017-05-13 22:17
#2
https://bbs.deepin.org/user/48640
能说下吗?
Reply
Like 0
View the author
Deepin大法好
deepin
2017-05-13 23:09
#3
同求,想自己写个小插件
https://bbs.deepin.org/user/48640
Reply
Like 0
View the author
linux0208
deepin
2017-05-14 00:20
#4
你可以研究一下pkexec命令
Reply
Like 0
View the author
rekols
deepin
2017-05-14 00:35
#5
不知道
Reply
Like 0
View the author
linux0208
deepin
2017-05-14 01:54
#6
本帖最后由 linux0208 于 2017-5-13 17:56 编辑
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY 你程序的绝对路径
Reply
Like 0
View the author
nevershow
deepin
2017-05-14 03:37
#7
from subprocess import Popen, PIPE
p = Popen('gksu command -m 输入密码以执行操作', shell = True, stdout = PIPE)
p.wait()
Reply
Like 0
View the author
Feng Yu
deepin
2017-05-14 04:25
#8
我的建议是不要这么麻烦,直接给出错误提示,告诉用户必须使用root权限执行即可。
如果你的程序是命令行程序,直接判断下当前用户的pid是不是0,否则给出用户提示,必须使用管理员身份运行,至于用户用的是sudo还是su就不管了。
如果是图形界面程序,在图形界面的执行命令上使用gksudo调用你的程序就完了,比如gparted就这么干的,你内部程序根本无需切换root
Reply
Like 0
View the author
星外之神
deepin
2017-05-14 05:08
#9
rekols 发表于 2017-5-13 16:35
不知道
大神最近在玩什么?
Reply
Like 0
View the author
wangyong
deepin
2017-05-14 05:22
#10
gksu 加上你写的程序的名字
Reply
Like 0
View the author
q1377195627
deepin
2017-05-14 09:55
#11
我也想知道,不过我用的是c++/qt
Reply
Like 0
View the author
iammsf
deepin
2017-05-14 11:09
#12
最簡單的,apt install gksu,然後把程序拖個桌面圖標出來,在屬性→命令那一行的最前面加上gksu即可,整個程序在只會在運行之前獲取一次root權限,運行過程中再也不需要額外的root授權了
Reply
Like 0
View the author
Please
sign
in first
Featured Collection
Change
Nuntia - Modern IMAP/SMTP mail client for Deepin (Beta tester wanted!)
[Tutorial] deepin25 WSL Offline Installation Guide
UOS AI 2.8 Released! Three New Intelligent Agents & Major Evolution
Solid Q&A | deepin 25 Common Questions – The Immutable System Edition
New Thread
Popular Ranking
Change
Four agent skills for laptop power, sleep, and honest bug reports
Installing qemu-user breaks deepin
Adding a Dancing Spectrum Bar to the Deepin Taskbar | deepin-spectrum
Popular Events
More