python 3.x - How to ask password for sudo using pyqt? -
cmd = subprocess.run(["sudo", "ovs-vsctl", "list-br"], stdout=subprocess.pipe, universal_newlines=true)
this error message gets shown when try run it.
sudo: no tty present , no askpass program specified
this pyqt5 application trying out. want know how can ask administrator password in gui app?
this code:
#!/usr/bin/python3 # -*- coding: utf-8 -*- import os, sys, design, subprocess pyqt5 import qtcore, qtgui, qtwidgets class exampleapp(qtwidgets.qmainwindow, design.ui_mainwindow): def __init__(self): super(self.__class__, self).__init__() self.setupui(self) self.button1.clicked.connect(self.browse_folder) def browse_folder(self): self.listwidget.clear() cmd = subprocess.run(["sudo", "ovs-vsctl", "list-br"], stdout=subprocess.pipe, universal_newlines=true) bridges = cmd.stdout.split('\n') if bridges: bridge in bridges: self.listwidget.additem(bridge) def main(): app = qtwidgets.qapplication(sys.argv) form = exampleapp() form.show() app.exec_() if __name__ == '__main__': main()
Comments
Post a Comment