1

There is a button that runs the os.system('sudo apt-get update')command when the button is clicked.

Simultaneously, I'd like to display a progress bar while the command are running.

Should I use Thread? How can I do this in PyQt5 ?

class MyApp(QMainWindow):
    def __init__(self):
        super(MyApp, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.Button.clicked.connect(self.onButtonClick)
    def onButtonClick(self):
        os.system('sudo apt-get update')

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MyApp()
    window.show()
    sys.exit(app.exec_())

Thank you for your help.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Ensar
  • 11
  • 1
  • 3
  • `apt-get` is not a GUI application and does not show a Qt progress bar. The Ubuntu `update-amanager` uses python libraries to support aptd and synaptics: https://bazaar.launchpad.net/~ubuntu-core-dev/update-manager/main/view/head:/UpdateManager/backend/ You can do the same. – Heap Underflow Dec 24 '19 at 15:07
  • Or you decide to display the output of `apt-get`: https://stackoverflow.com/questions/52269950/how-to-embed-terminal-inside-pyqt5-application-without-qprocess – Heap Underflow Dec 24 '19 at 15:11
  • Where is the QProgressBar?.. – eyllanesc Dec 24 '19 at 17:45
  • I did not add the QProgressbar to know where to use and how to use it. How else can I do this? Any ideas? – Ensar Dec 24 '19 at 18:39
  • Any suggestions? – Ensar Dec 25 '19 at 13:31
  • @EnsarKarabudak Your question is confusing, you could detail what you want. Please use `@username` – eyllanesc Dec 25 '19 at 22:11

0 Answers0